package design_pattern.open_close.improve;


/**
 * @Name : open_close.GraphiceEditor
 * @Description : 描述
 * Created by cyd on 2020-12-14 13:49:40
 */
public class GraphicEditor {
    public void drawShape(Shape s) {
        s.draw();
    }
}

abstract class Shape {

    abstract void draw();
}

class Rectangle extends Shape {

    @Override
    void draw() {
        System.out.println("绘制矩形");
    }
}

class Circle extends Shape {

    @Override
    void draw() {
        System.out.println("绘制圆形");
    }
}

//增加三角形
class Triangle extends Shape {

    @Override
    void draw() {
        System.out.println("绘制三角形");
    }
}

class Tester {
    public static void main(String[] args) {
        GraphicEditor graphicEditor = new GraphicEditor();
        graphicEditor.drawShape(new Circle());
        graphicEditor.drawShape(new Rectangle());
        //画三角形
        graphicEditor.drawShape(new Triangle());
    }
}
